package com.ms.pda.utils;

import androidx.annotation.Nullable;

import java.text.SimpleDateFormat;
import java.util.Date;

public class StringUtils {
    public static String date2String(Date date, String pattern) {
        try {
            SimpleDateFormat format = new SimpleDateFormat(pattern);
            return format.format(date);
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }

    public static int string2Int(@Nullable String number) {
        if (number == null) {
            return 0;
        }
        try {
            return Integer.parseInt(number);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return 0;
    }
}
